package main

import "fmt"

func createCounter() func() int {
	i := 0
	return func() int {
		i++
		return i
	}
}

func main() {
	func() {
		sum := 0
		for i := 1; i <= 1e6; i++ {
			sum += i
		}
	}()
	counter1 := createCounter()
	counter2 := createCounter()
	fmt.Println(counter1()) // 1
	fmt.Println(counter1()) // 2
	fmt.Println(counter1()) // 2
	fmt.Println(counter1()) // 2
	fmt.Println(counter1()) // 2
	fmt.Println(counter2()) // 1
	fmt.Println(counter2()) // 2
}
